home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / languages / turbo_part1.lha / modula / m2 / BIO.def next >
Encoding:
Modula Definition  |  1994-12-28  |  3.9 KB  |  121 lines

  1. (* The REAL & LONGREAL functions (PutReal etc) requice 'C' floating point *)
  2. (* so will not work with the unregisterd version of DICE                  *)
  3. (* If you have the registered version of DICE then you must               *)
  4. (* link with the math library, either:                              *)
  5. (* m2l x -lm or m2b x -lm , alternatively set -lm in the DCCOPTS env var  *)
  6. (* This is only required if you use the floating point functions:         *)
  7. (* If you only use PutChar etc, you dont need to link the math library    *)
  8.  
  9. DEFINITION MODULE BIO ;
  10.  
  11. (* Basic I/O system. *)
  12.  
  13. PROCEDURE PutChar( Ch : CHAR ) ;
  14. (* Print a character *)
  15.  
  16. PROCEDURE PutInteger( int : LONGINT ) ;
  17. (* Print an integer, using the minimum width necessary *)
  18.  
  19. PROCEDURE PutReal( real : REAL ) ;
  20. (* Print a real, using the minimum width necessary *)
  21.  
  22. PROCEDURE PutRealFmt( r : REAL ; width, decplaces : LONGINT ) ;
  23. (*
  24.  * Prints a real, formatting the value so that it is right justified in
  25.  * a field of the given width, and contains the given number of decimal places.
  26.  *)
  27.  
  28. PROCEDURE PutLongReal( longreal : LONGREAL ) ;
  29. (* Print a long real, using the minimum width necessary *)
  30.  
  31. PROCEDURE PutLongRealFmt( r : LONGREAL; width, decplaces : LONGINT ) ;
  32. (*
  33.  * Prints a longreal, formatting the value so that it is right justified in
  34.  * a field of the given width, and contains the given number of decimal places.
  35.  *)
  36.  
  37. PROCEDURE PutString( str : ARRAY OF CHAR ) ;
  38. (* Print a string, using the minimum width necessary *)
  39.  
  40. PROCEDURE PutLine( ) ;
  41. (* Prints a newline character *)
  42.  
  43. PROCEDURE PutLn( str : ARRAY OF CHAR ) ;
  44. (* Print a string followed by a newline *)
  45.  
  46. PROCEDURE GetChar( VAR Ch : CHAR ) ;
  47. (* Get a character.  Unexpected end-of-stream causes a fatal runtime error *)
  48.  
  49. PROCEDURE GetInteger( VAR int : LONGINT ) ;
  50. (*
  51.  * Get an integer, first removing leading whitespace.
  52.  * Incorrect input results in a message "Not an INTEGER.  Try again".
  53.  * Unexpected end-of-stream causes a fatal runtime error.
  54.  *)
  55.  
  56. PROCEDURE GetReal( VAR real : REAL ) ;
  57. (*
  58.  * Get a real, first removing leading whitespace.
  59.  * Incorrect input results in a message "Not a REAL.  Try again".
  60.  * Unexpected end-of-stream causes a fatal runtime error.
  61.  *)
  62.  
  63. PROCEDURE GetLongReal( VAR longReal : LONGREAL ) ;
  64. (*
  65.  * Get a longreal, first removing leading whitespace.
  66.  * Incorrect input results in a message "Not a LONGREAL.  Try again".
  67.  * Unexpected end-of-stream causes a fatal runtime error.
  68.  *)
  69.  
  70. PROCEDURE GetString( VAR str : ARRAY OF CHAR ) ;
  71. (*
  72.  * Gets a single WORD, ie. whitespace terminated.
  73.  * Unexpected end-of-stream causes a fatal runtime error.
  74.  *)
  75.  
  76. PROCEDURE GetLn( VAR str : ARRAY OF CHAR ) ;
  77. (*
  78.  * Gets the entire line (discarding any surplus that doesn't fit into the
  79.  * array).  No leading whitespace is skipped, and the trailing newline is
  80.  * discarded rather than stored.
  81.  * Unexpected end-of-stream causes a fatal runtime error.
  82.  *)
  83.  
  84. PROCEDURE GetLine( ) ;
  85. (*
  86.  * Discard the rest of the current line - including the newline.
  87.  * Unexpected end-of-stream causes a fatal runtime error.
  88.  *)
  89.  
  90. PROCEDURE IsMore( ) : BOOLEAN ;
  91. (*
  92.  * Returns: FALSE if the end of the input stream has been reached,
  93.  *        TRUE otherwise
  94.  *)
  95.  
  96. PROCEDURE IsEndOfLine( ) : BOOLEAN ;
  97. (*
  98.  * Returns: TRUE if the end of the current line has been reached,
  99.  *        FALSE otherwise.
  100.  * Warning: even if we return TRUE, the newline character is not removed,
  101.  *        so don't forget to discard it with GetLine or GetChar.
  102.  *)
  103.  
  104. PROCEDURE InspectChar( ) : CHAR ;
  105. (*
  106.  * Inspect the next character without advancing past it.  If we're at the
  107.  * end-of-stream, an undefined character is returned; it is not a fatal
  108.  * runtime error.  It is better to check IsMore() before using this.
  109.  *)
  110.  
  111. PROCEDURE PushBackChar( c : CHAR ) ;
  112. (*
  113.  * Push back the given character onto the input.
  114.  * Warning: Only one character of pushback is guaranteed.
  115.  *)
  116.  
  117. PROCEDURE Flush( ) ;
  118. (* Flush the input and output. Rarely needed. *)
  119.  
  120. END BIO.
  121.